#!/usr/bin/perl
#
# This code is distributed under the terms of the GPL
#
# (c) Scott Knight 2004
# (c) Tiago Freitas Leal
# (c) The Smoothwall Team
#
# Install script for TCP/UDP adder
# Mod Author: J.Delong aka hype8912
# Release Date: 10/08/2007

require '/var/smoothwall/mods/tcp-udp_adder/modlib.pl';

# # # # # # # # # # # # # # # # # # #
# check for existing installations  #
# # # # # # # # # # # # # # # # # # #

if (-e "/var/smoothwall/mods/tcp-udp_adder/installed")
{
	if (&installed ("/var/smoothwall/mods/tcp-udp_adder/installed", "# TCP/UDP Adder v1.0"))
	{
		print "\nPlease remove TCP/UDP Adder v1.0\n";
		print "Note - Run uninstall.pl script.\n\n";
		exit;
	}
}

# # # # # # # # # # # #
# handle file copying #
# # # # # # # # # # # #

#	$storebkp =	where to store backup of the files that are changed by your mod
#	$moddir =	where your mod files are
#	$wkdir =	where you are changing files (backup from and copy to)
#
#	backupinstall ($file, $wkdir, $storebkp, $moddir);
#	backup ($file, $wkdir, $storebkp);
#	install ($file, $wkdir, $moddir);
#	uninstallrestore ($file, $wkdir, $storebkp);
#	uninstall ($file , $wkdir);
#
#	installed ($file, $string);
#
#	search for $string into $file => 1 found / 0 not found

my $mod = '/var/smoothwall/mods/tcp-udp_adder/modfiles';
my $bkp = '/var/smoothwall/mods/tcp-udp_adder/backup';

print "Backing up files ...\n";
$dir = '/httpd/cgi-bin';
&backup ('portfw.cgi', $dir, $bkp);
&backup ('dmzholes.cgi', $dir, $bkp);
&backup ('xtaccess.cgi', $dir, $bkp);

print "Installing new files ...\n";
&install ('portfw.cgi', $dir, $mod);
&install ('dmzholes.cgi', $dir, $mod);
&install ('xtaccess.cgi', $dir, $mod);


# # # # # # # # # # # #
# handle file editing #
# # # # # # # # # # # #


# # # # # # # # # # # #
# handle file linking #
# # # # # # # # # # # #

print "Done\n\n";

# # # #
# end #
# # # #
